using System;
using System.Reflection;
using System.Runtime.CompilerServices;

namespace OpenSource.SpreadsheetFactory.Internal
{
    internal sealed class PropertyColumn<T> : Column<T>
    {
        private PropertyInfo Property { get; set; }

        internal PropertyColumn(PropertyInfo property) : base(property)
        {
            this.Property = property;
        }

        internal sealed override Type GetColumnType()
        {
            return this.Property.PropertyType;
        }

        internal sealed override object GetColumnValue(T instance)
        {
            return this.Property.GetValue(instance, null);
        }

        protected sealed override MemberInfo Member
        {
            get
            {
                return this.Property;
            }
        }
    }
}

